//
//  ProfileProjectCell.swift
//  AmountBody
//
//  Created by Qiu Jishuai on 2018/1/25.
//  Copyright © 2018年 RCMTM. All rights reserved.
//

import UIKit

class ProfileProjectCell: UITableViewCell {

    let images = [#imageLiteral(resourceName: "我的客户"), #imageLiteral(resourceName: "我的面料"), #imageLiteral(resourceName: "面料信息"), #imageLiteral(resourceName: "发货查询"), #imageLiteral(resourceName: "我的返修"), #imageLiteral(resourceName: "我的mto"), #imageLiteral(resourceName: "在线派工")]
    let leftLineView = LeftLineView()
    let containerView = UIView()
    var buttons: [UIButton] = []

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)

        leftLineView.titleLabel.text = "我的项目"
        contentView.addSubview(leftLineView)
        leftLineView.mas_makeConstraints { (make) in
            make?.left.equalTo()(contentView)?.offset()(30)
            make?.top.equalTo()(contentView)?.offset()(25)
        }

        contentView.addSubview(containerView)
        containerView.mas_makeConstraints { (make) in
            make?.top.equalTo()(leftLineView.mas_bottom)?.offset()(30)
            make?.left.width().equalTo()(contentView)
            make?.bottom.equalTo()(contentView)?.offset()(-25)
        }

        for (index, image) in images.enumerated() {
            let button = UIButton(type: .system)
            button.setImage(image.alwaysOriginal(), for: .normal)
            button.tag = index
            containerView.addSubview(button)
            buttons.append(button)
        }
          addLine(on: .bottom, color: .gray, lineWidth: 1 / UIScreen.main.scale, inset: UIEdgeInsets(top: 0, left: 30, bottom: 0, right: 30))
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func layoutSubviews() {
        super.layoutSubviews()

        containerView.distributeSquareSubviews(buttons, type: .autoLayout)
    }
}


